/*
 * REFXMLContentValidator.h
 *
 *  Created on: Apr 1, 2013
 *      Author: Lucifer
 */

#ifndef	__BFX_REFXMLCONTENTVALIDATOR_H__
#define	__BFX_REFXMLCONTENTVALIDATOR_H__

#include "../../pch.h"
#include "../core/REFXMLQualifiedName.h"

namespace BFX
{

enum XMLSchemaContentType
{
    XMLSchemaContentType_TextOnly,
    XMLSchemaContentType_Empty,
    XMLSchemaContentType_ElementOnly,
    XMLSchemaContentType_Mixed
};

//////////////////////////////////////////////////////////////////////////////

class REFXMLContentValidator : public REFObject
{
public:
	REFXMLContentValidator(XMLSchemaContentType contentType);
	REFXMLContentValidator(XMLSchemaContentType contentType, bool bIsOpen, bool bIsEmptiable);
	virtual ~REFXMLContentValidator();

	static REFXMLContentValidator* Empty();
	static REFXMLContentValidator* Any();

protected:
	bool	m_bIsOpen;			//For XDR Content Models or ANY
	bool	m_bIsEmptiable;
};

//////////////////////////////////////////////////////////////////////////////

inline REFXMLContentValidator::REFXMLContentValidator(XMLSchemaContentType contentType)
	: m_bIsOpen(false), m_bIsEmptiable(false)
{
}
inline REFXMLContentValidator::REFXMLContentValidator(XMLSchemaContentType contentType, bool bIsOpen, bool bIsEmptiable)
	: m_bIsOpen(false), m_bIsEmptiable(false)
{
}
inline REFXMLContentValidator::~REFXMLContentValidator()
{
}

inline REFXMLContentValidator* REFXMLContentValidator::Empty()
{
	REFXMLContentValidator* pcv = new REFXMLContentValidator(XMLSchemaContentType_Empty);
	pcv->Autorelease();
	return pcv;
}
inline REFXMLContentValidator* REFXMLContentValidator::Any()
{
	REFXMLContentValidator* pcv= new REFXMLContentValidator(XMLSchemaContentType_Mixed, true, true);
	pcv->Autorelease();
	return pcv;
}

//////////////////////////////////////////////////////////////////////////////

class REFXMLParticleContentValidator: public REFXMLContentValidator
{
public:
	REFXMLParticleContentValidator(XMLSchemaContentType contentType);
	REFXMLParticleContentValidator(XMLSchemaContentType contentType, bool bEnableUpaCheck);

	void Start();
	void OpenGroup();
	void CloseGroup();
	REFXMLContentValidator* Finish();
	bool Exists(REFXMLQualifiedName* pName);

	void AddStar();
	void AddQMark();
	void AddPlus();
	void AddSequence();
	void AddChoice();
	void AddName(REFXMLQualifiedName* pName);

private:
	bool	m_bEnableUpaCheck;
};

//////////////////////////////////////////////////////////////////////////////

inline REFXMLParticleContentValidator::REFXMLParticleContentValidator(XMLSchemaContentType contentType)
	: REFXMLContentValidator(contentType)
{
	m_bEnableUpaCheck = false;
}
inline REFXMLParticleContentValidator::REFXMLParticleContentValidator(XMLSchemaContentType contentType, bool bEnableUpaCheck)
	: REFXMLContentValidator(contentType)
{
	m_bEnableUpaCheck = false;
}

inline void REFXMLParticleContentValidator::Start()
{
	//printf("pvc::Start\n");
}
inline void REFXMLParticleContentValidator::OpenGroup()
{
	//printf("pvc::OpenGroup\n");
}
inline void REFXMLParticleContentValidator::CloseGroup()
{
	//printf("pvc::CloseGroup\n");
}
inline REFXMLContentValidator* REFXMLParticleContentValidator::Finish()
{
	//printf("pvc::Finish\n");
	return REFXMLContentValidator::Empty();
}
inline bool REFXMLParticleContentValidator::Exists(REFXMLQualifiedName* pName)
{
	//printf("pvc::Exists\n");
	return false;
}

inline void REFXMLParticleContentValidator::AddStar()
{
	//printf("pvc::AddStar\n");
}
inline void REFXMLParticleContentValidator::AddQMark()
{
	//printf("pvc::AddQMark\n");
}
inline void REFXMLParticleContentValidator::AddPlus()
{
	//printf("pvc::AddPlus\n");
}
inline void REFXMLParticleContentValidator::AddSequence()
{
	//printf("pvc::AddSequence\n");
}
inline void REFXMLParticleContentValidator::AddChoice()
{
	//printf("pvc::AddChoice\n");
}
inline void REFXMLParticleContentValidator::AddName(REFXMLQualifiedName* pName)
{
	//printf("pvc::AddName\n");
}

}	//	namespace BFX

#endif	//	__BFX_REFXMLCONTENTVALIDATOR_H__
